<%@page import="java.sql.ResultSet"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>my page</title>
<style type="text/css">
*{
	margin:0px;
	padding:0px;
}
#image1{
      
	  background:url(image/1.jpg);
	  background-position:center;
	  background-size:cover;
	  filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
      src='image/1.jpg',
      sizingMethod='scale');
	  
	  width:1350px;
	  height:1000px;
	  z-index:-1;
	  background-repeat:no-repeat;
}
.center{/*这是控制中间的部分的样式表*/
     width:920px;
     height:1000px;
     top:10px;
     left:200px;
     position:absolute;
}
#image2{ 
		background:url(image/2.jpg);
		width:100%;
		height:356px;
		background-repeat:no-repeat;
		
}
#people{
	background:url(image/people.jpg);
	width:100px;
	height:100px;
	top:50px;
	left:43%;
	position:absolute;
}

#nickname{
      top:150px;
      left:390px;
      position:absolute;
}
.left{
	width:300px;
	height:680px;
	margin-top:10px;
	margin-right:10px;
	background-color:white;
	top:85%;
	float:left;
	position:relative;
	
}
.right{
width:610px;
height:680px;
margin-top:10px;
background-color:white;
top:85%;
float:left;
position:relative;
}
/*下面是关于left部分的布局*/
#left1{
width:300px;
height:60px;
background-color:white;
}
#honor{
width:300px;
height:90px;
background:white;
}
/*下面是关于右边的布局*/
#right1{
 
	top:20px;
	float:left;
	position:relative;
	
}
/*下面是底部的布局*/
#bottom{
background:url(image/3.png);
width:1350px;
height:260px;
}
a:link{color:blue}
a:visited{color:red}
</style>

<script   language="javascript"   type="text/javascript">
 var   xmlDoc;   
 var   nodeIndex; 
  function   getxmlDoc()   
  {   
      xmlDoc=new   ActiveXObject("Microsoft.XMLDOM");   
          var   currNode;   
          xmlDoc.async=false;   
          xmlDoc.load("source/Area.xml");   
          if(xmlDoc.parseError.errorCode!=0)   
          {   
                  var   myErr=xmlDoc.parseError;   
                  alert("出错！"+myErr.reason);   
          }           
  }
  function Init()
  {
    //打开xlmdocm文档
    getxmlDoc();
    var   dropElement1=document.getElementById("Select1"); 
    var   dropElement2=document.getElementById("Select2"); 
    var   dropElement3=document.getElementById("Select3");   
    RemoveDropDownList(dropElement1);
    RemoveDropDownList(dropElement2);
    RemoveDropDownList(dropElement3);
    var  TopnodeList=xmlDoc.selectSingleNode("address").childNodes;
    if(TopnodeList.length>0)
    {
        //省份列表
        var country;
        var province;
        var city;
        for(var   i=0; i<TopnodeList.length;   i++)
        {
              //添加列表项目
              country=TopnodeList[i];       
              var   eOption=document.createElement("option");   
              eOption.value=country.getAttribute("name");
              eOption.text=country.getAttribute("name");
              dropElement1.add(eOption);
        }
        if(TopnodeList[0].childNodes.length>0)
        {
            //城市列表
            for(var i=0;i<TopnodeList[0].childNodes.length;i++)
            {
               var   id=dropElement1.options[0].value;
               //默认为第一个省份的城市
               province=TopnodeList[0]; 
               var   eOption=document.createElement("option");  
               eOption.value=province.childNodes[i].getAttribute("name");   
               eOption.text=province.childNodes[i].getAttribute("name");   
               dropElement2.add(eOption);
            }
            if(TopnodeList[0].childNodes[0].childNodes.length>0)
            {
               //县列表
               for(var i=0;i<TopnodeList[0].childNodes[0].childNodes.length;i++)
               {
                  var   id=dropElement2.options[0].value;
                  //默认为第一个城市的第一个县列表
                  city=TopnodeList[0].childNodes[0];  
                  var   eOption=document.createElement("option");  
                  eOption.value=city.childNodes[i].getAttribute("name");   
                  eOption.text=city.childNodes[i].getAttribute("name");   
                  this.document.getElementById("Select3").add(eOption);
               }
            }
        }
    }
  }   
  function   selectCity()   
  {       var   dropElement1=document.getElementById("Select1"); 
          var   name=dropElement1.options[dropElement1.selectedIndex].value;
          //alert(id);
          var   countryNodes=xmlDoc.selectSingleNode('//address/province [@name="'+name+'"]');   
          //alert(countryNodes.childNodes.length); 
          var   province=document.getElementById("Select2");       
          var   city=document.getElementById("Select3");       
          RemoveDropDownList(province);   
          RemoveDropDownList(city);
          if(countryNodes.childNodes.length>0)
          {
               //填充城市          
               for(var   i=0;   i<countryNodes.childNodes.length;   i++)   
               {   
                  var   provinceNode=countryNodes.childNodes[i];     
                  var   eOption=document.createElement("option");   
                  eOption.value=provinceNode.getAttribute("name");   
                  eOption.text=provinceNode.getAttribute("name");   
                  province.add(eOption);   
               }
               if(countryNodes.childNodes[0].childNodes.length>0)
               {
                  //填充选择省份的第一个城市的县列表
                  for(var i=0;i<countryNodes.childNodes[0].childNodes.length;i++)
                  {
                     
                      var   dropElement2=document.getElementById("Select2"); 
                      var   dropElement3=document.getElementById("Select3"); 
                      //取当天省份下第一个城市列表
                      var cityNode=countryNodes.childNodes[0];
                      //alert(cityNode.childNodes.length); 
                      var   eOption=document.createElement("option");  
                      eOption.value=cityNode.childNodes[i].getAttribute("name");   
                      eOption.text=cityNode.childNodes[i].getAttribute("name");   
                      dropElement3.add(eOption);
                  }
               }
          }
  }   
  function   selectCountry()   
  {   
          var   dropElement2=document.getElementById("Select2");   
          var   name=dropElement2.options[dropElement2.selectedIndex].value;   
          var   provinceNode=xmlDoc.selectSingleNode('//address/province/city[@name="'+name+'"]');   
          var   city=document.getElementById("Select3");       
          RemoveDropDownList(city);   
          for(var   i=0;   i<provinceNode.childNodes.length;   i++)   
          {   
                  var   cityNode=provinceNode.childNodes[i];     
                  var   eOption=document.createElement("option");   
                  eOption.value=cityNode.getAttribute("name");   
                  eOption.text=cityNode.getAttribute("name");   
                  city.add(eOption);   
          }   
  }   
  function   RemoveDropDownList(obj)   
  {   
      if(obj)
      {
          var   len=obj.options.length;   
          if(len>0)
          {
            //alert(len);   
            for(var   i=len;i>=0;i--)   
            {   
                  obj.remove(i);   
            }
          }
       }
            
  }   
   
  function change(){
     write.innerHTML="<button  disabled >编辑</button>"
	 loginName.innerHTML="账号：<input type='text' name='loginName' value="+loginName.innerText.substring(4)+">";
	 password.innerHTML="密码：<input type='text' name='password' value="+password.innerText.substring(3)+">";
	 nickName.innerHTML="昵称：<input type='text' name='nickName' value="+nickName.innerText.substring(3)+">";
	 realName.innerHTML="真实姓名：<input type='text' name='realName' value="+realName.innerText.substring(5)+">";
	 adress.innerHTML="所在地：<select id='Select1' name='province' runat='server' onchange='selectCity();'><option value='' selected='true'>省/直辖市</option></select><select id='Select2' name='city' runat='server' onchange='selectCountry()'><option value='' selected='true'>请选择</option></select><select id='Select3' name='district' runat='server' ><option value='' selected='true'>请选择</option></select>";
	 sex.innerHTML="性别：<label><input type='radio' name='sex' checked='checked'/>男</label><label><input type='radio' name='sex'/>女</label>";
	 emotion.innerHTML="感情状况：<label><input type='radio' name='emotion' checked='checked'/>已婚</label><label><input type='radio' name='emotion'/>未婚</label>";;
	 birthday.innerHTML="生日：<input type='text' name='birthday' value="+birthday.innerText.substring(3)+">";
	 introduction.innerHTML="<div style='float:left'>简介：</div><textarea name='introduction' clos='20' rows='5' >"+introduction.innerText.substring(3)+"</textarea>";
	 identify.innerHTML="身份证号：<input type='text' name='identify' value="+identify.innerText.substring(5)+">";
	 email.innerHTML="邮箱：<input type='text' name='email' value="+email.innerText.substring(3)+">";
	 image.innerHTML="头像: <input type='file' name='file'> ";
	 shuru.innerHTML="<br/><div style='width:90%; top:7px;float:left; position:relative'><hr/></div><div><button style='height:30px' type='submit'>提交</button></div>";
	 Init();
}

 </script>
</head>
<body >
<% 
    
	java.sql.Connection conn = null;
    String strConn=null;
    java.sql.Statement state=null;
    ResultSet set=null;
    ResultSet set2=null;
    String account=null;
    
    if(request.getParameter("account")!=null){
    	account=request.getParameter("account");
    }else{
    	account = (String)session.getAttribute("user");	
    	}
	String sql = "select * from user1 where account='"+account+"'";
    System.out.println(sql);
    try{
    	Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    	conn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/school1130", "root", "root");
    	state = conn.createStatement();
    	set =state.executeQuery(sql);
    	set.next();
    	String s2=(String)set.getString("nickname");
    	 String identify=(String)set.getString("identify");
    	Integer schoolNum = (Integer)set.getInt("school_num");
        
String contextPath = request.getContextPath();        
%>
        
	<div id="image1">
		<div class="center">
			<div id="image2">
				<div id="people"></div>
				 <div id="nickname" style="left:45%;"> <br/><% out.print(s2);%></div>
			    <div class="left">
		        	<div id="left1">
		        	<table width="100%" height="100%"  cellspacing="0" cellpadding="0">
		        		<tr>
		        		<td>关注:<a href="MyPageFocus.jsp">5</a></td>
		        		<td>粉丝:<a href="MyPageFocus.jsp">10</a></td>
		        		<td>微博:<a href="mypost.jsp">8</a></td>
		        		</tr>
		        	</table>
		        	<hr style="width:100%"/>
		        	</div>
		        	<br/>
		            <div id="honor">
		            	<b>荣誉信息</b><br/>
		            	<div style="font-size:15px; line-height:20px;">
		            	<br/>
		            	<% 
		            		 s2=(String) set.getString("level");
		            	    String s3=(String) set.getString("score"); 
		            	%>
		            	等级信息：<font color='blue'><%out.println(s2); %></font> level<br/>
		                                      积分信息：<font color='blue'> <%out.println(s3); %></font>score<br/>
		                                    距离下一级还有:<font color='blue'>&nbsp 36</font><br/>
		            	</div>
		              </div>
		            <hr/>
		            <div style="background:url(image/left1.PNG); width:100%;height:265px;"></div>
		            <div style="background:url(image/left3.PNG); width:100%;height:120px;"></div>   
			    </div>
			   <div class="right">
			    	<div id="right1">
			    	基本信息
			    	</div>
			        <div style="top:20px; width:80%; float:left;position:relative"><hr/></div>
			    	<div style="top:15px;position:relative" id="write"><button onclick="change()" >编辑</button></div>
			    	<br/><br/>
			    	<%
			    	    
			    	    String password =(String)set.getString("password");
			    	    String nickname=(String)set.getString("nickname");
			    	    s2 = "select * from user2 where account='"+account+"'";
			    	    set2 = state.executeQuery(s2);
			    	    set2.next();
			    	    s2 = (String)set2.getString("name");
			    	    
			    	    String province = (String)set2.getString("province");
			    	    String city = (String)set2.getString("city");
			    	    String adress=(String)set2.getString("address");
			    	    String s = province+city+adress;
			    	    String sex = (String)set2.getString("sex");
			    	    String emotion= (String)set2.getString("emotion");
			    	    String birthday=(String)set2.getString("birthday");
			    	    String introduction=(String)set2.getString("introduction");
			    	    String registerTime=(String)set2.getString("register_date");
			    	    String email = (String)set2.getString("email");
			    	    String school=(String)set2.getString("school");
			    	    String studyYear =(String)set2.getString("length_of_schooling");
			    	    %>
			    	<form method="post" action="<%=contextPath %>/SaveSuccess.jsp" id="form1"  runat="server" enctype="multipart/form-data" ><!-- runat="server" enctype="multipart/form-data" -->
			    	<div style="font: 14px/1.125 Arial,Helvetica,sans-serif;line-height: 30px;color:#999999">
			    	
			    	<div id="loginName">登录名：<%out.print(account); %></div>
			    	<div id="password">密码：<%out.print(password); %></div>
			    	<div id="nickName">昵称：<%out.print(nickname); %></div>
			    	<div id="realName">真实姓名：<%out.print(s2); %></div>
			    	<div id="adress" ><div style='float:left'>所在地：</div><div id='province' style='float:left'><%out.print(province); %></div><div id='city' style='float:left'><%out.print(city);%></div><div id='district' ><% out.print(adress);%></div></div>
			    	<div id="sex">性别：<% if(sex.equals("on")){out.print("男");}else{out.print("女");} %></div>
			    	<div id="emotion">感情状况：<%if(sex.equals("on")){out.print("已婚");}else{out.print("未婚");} %></div>
			    	<div id="birthday">生日：<%out.print(birthday); %></div>
			    	<div id="introduction">简介：<%out.print(introduction); %></div>
			    	<div id="identify">身份证号：<%out.print(identify); %></div>
			    	<div id="registerTime">注册时间：<%out.print(registerTime); %></div>
			    	<div id="email">邮箱：<%out.print(email);%></div>
			    	<div id="schoolName">学校名称：<%out.print(school); %></div>
			    	<div id="schoolNum">学校编号：<%out.print(schoolNum); %></div>
			    	<div id="studyYear">学制：<%out.print(studyYear); %></div>
			    	<div id="image"></div>
			    	<div id="shuru" style="width:610px"></div>
			        </div >
			    	</form>
			</div>
		</div>
	</div>
	
</div>
<%
    }catch(Exception e){
    	
    	e.printStackTrace();
    }finally{
    	set2.close();
    	set.close();
    	state.close();
    	conn.close();
    }
   %>
	
<div id="bottom"> </div>
<div>
</div>
</body>
</html>